package com.scf.common;

import com.scf.common.utils.ValidateUtil;
import com.scf.common.vo.DemoInfo;
import com.scf.common.vo.GroupA;
import com.scf.common.vo.UserDTO;
import com.scf.common.vo.ValidationResult;

import java.util.ArrayList;
import java.util.List;

/**
 * @author sunchuanfu
 */
public class Test {
    public static void main(String[] args) {
        DemoInfo bean = new DemoInfo();
        // bean.setType("abc");
        // bean.setAppName("1234");
        // bean.setDigits("10.2");


        // bean.setDigits("123456789012340.01");
        // bean.setPositive(0);
        // bean.setDecimalMax("abc");
        bean.setMax(200);

        List<UserDTO> userDTOList = new ArrayList<>();
        UserDTO userDTO = new UserDTO();
        userDTO.setUserId(1L);
        userDTOList.add(userDTO);
        bean.setUserDTOList(userDTOList);

        // bean.setDetailType(100);
        // ValidationResult validationResult = ValidateUtil.validateEntity(bean);
        ValidationResult validationResult = ValidateUtil.validateEntityByGroup(bean, GroupA.class);// 未指定Group的验证项不公触发，但是实际项目里会触发 TODO
        // ValidationResult validationResult = ValidateUtil.validateProperty(bean, "digits");
        // ValidationResult validationResult = ValidateUtil.validateProperty(bean, "max");
        // ValidationResult validationResult = ValidateUtil.validateEntityByGroup(bean, GroupA.class, GroupB.class);
        System.out.println(validationResult.getMessage());
    }
}
